package com.gg.redisbootservice.handler;

import com.gg.redisbootservice.enums.RedisTemPlateEnum;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author gg
 * @version RedisTemplateHandler.java, v 0.1 2019-04-04 16:46 gg
 */
@Component
public class RedisTemplateHandler {

    @Resource
    private RedisTemplate<String,Object> firstRedisTemplate;

    @Resource
    private RedisTemplate<String,Object> secondRedisTemplate;

    @Resource
    private RedisTemplate<String,Object> thirdRedisTemplate;

    public RedisTemplate<String,Object> handler(RedisTemPlateEnum redisTemPlateEnum) {
        switch (redisTemPlateEnum) {
            case FIRST:
                return firstRedisTemplate;
            case SECOND:
                return secondRedisTemplate;
            case THIRD:
                return thirdRedisTemplate;
            default:
                throw new IllegalArgumentException("redisTemplate type Error");
        }
    }

}